(function(){"use strict";BX.namespace("BX.Landing");BX.Landing.CardGalleryCollection=function(){this.galleries={}};BX.Landing.CardGalleryCollection.getInstance=function(){return BX.Landing.CardGalleryCollection.instance||(BX.Landing.CardGalleryCollection.instance=new BX.Landing.CardGalleryCollection)};BX.Landing.CardGalleryCollection.initBlock=function(a){if(BX.Landing.CardGallery.isGalleryBlock(a)){var n=this.getInstance();n.add(a)}};BX.Landing.CardGalleryCollection.disableBlock=function(a){if(BX.Landing.CardGallery.isGalleryBlock(a)){var n=new BX.Landing.CardGallery(a);n.disable()}};BX.Landing.CardGalleryCollection.prototype={add:function(a){var n=new BX.Landing.CardGallery(a);n.initImages();this.galleries[n.getId()]=n},findGalleryByBlock:function(a){return this.galleries[a.id]||null}};BX.Landing.CardGallery=function(a){this.uniqId=a.id;this.gallery=BX.Landing.CardGallery.getGalleryNode(a)};BX.Landing.CardGallery.isGalleryBlock=function(a){return this.getGalleryNode(a)!==null};BX.Landing.CardGallery.getGalleryNode=function(a){return a.querySelector(this.GALLERY_SELECTOR)};BX.Landing.CardGallery.GALLERY_SELECTOR=".js-gallery-cards";BX.Landing.CardGallery.IMAGES_SELECTOR="[data-fancybox]";BX.Landing.CardGallery.DATA_FANCYBOX="fancybox";BX.Landing.CardGallery.DATA_FANCYBOX_INITIED="fancyboxInitied";BX.Landing.CardGallery.DATA_FANCYBOX_TITLE="caption";BX.Landing.CardGallery.DATA_LINK_CLASSES="linkClasses";BX.Landing.CardGallery.DATA_LAZY_IMAGE="lazyImg";BX.Landing.CardGallery.CAROUSEL_CLONED_CLASSES="slick-cloned";BX.Landing.CardGallery.prototype={getId:function(){return this.uniqId},disable:function(){var a=[].slice.call(this.gallery.querySelectorAll(BX.Landing.CardGallery.IMAGES_SELECTOR));a.forEach(function(a){delete a.dataset[BX.Landing.CardGallery.DATA_FANCYBOX]},this)},initImages:function(){var a=[].slice.call(this.gallery.querySelectorAll(BX.Landing.CardGallery.IMAGES_SELECTOR));a.forEach(function(a){if(BX.findParent(a,{class:BX.Landing.CardGallery.CAROUSEL_CLONED_CLASSES})){return}if(!this.isImageInit(a)){this.addOuterLink(a)}},this)},isImageInit:function(a){return a.tagName==="IMG"&&a.dataset[BX.Landing.CardGallery.DATA_FANCYBOX_INITIED]==="Y"||a.tagName==="A"&&a.firstChild!==null&&this.isImageInit(a.firstChild)},addOuterLink:function(a){var n;var l;if(a.dataset[BX.Landing.CardGallery.DATA_LAZY_IMAGE]==="Y"){n=a.dataset.src||a.src;l=a.dataset.srcset||a.srcset}else{n=a.src;l=a.srcset}if(!n){return}var e=a.parentNode;var i=BX.create("a",{attrs:{href:n,class:a.dataset[BX.Landing.CardGallery.DATA_LINK_CLASSES]||""},children:[].slice.call(e.children)});if(l){l=n+" 1x,"+l;i.dataset.options='{"image":{"srcset": "'+l+'"}}'}BX.adjust(e,{children:[i]});i.dataset[BX.Landing.CardGallery.DATA_FANCYBOX]=a.dataset[BX.Landing.CardGallery.DATA_FANCYBOX]+"_"+this.uniqId;i.dataset[BX.Landing.CardGallery.DATA_FANCYBOX_TITLE]=BX.Text.encode(a.getAttribute("alt"))||"";delete a.dataset[BX.Landing.CardGallery.DATA_FANCYBOX];a.dataset[BX.Landing.CardGallery.DATA_FANCYBOX_INITIED]="Y"}};BX.addCustomEvent("BX.Landing.Block:init",function(a){if(BX.Landing.getMode()==="edit"){BX.Landing.CardGalleryCollection.disableBlock(a.block)}else{BX.Landing.CardGalleryCollection.initBlock(a.block)}})})();
//# sourceMappingURL=gallery_cards_init.map.js